<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/activity.php');
require_once ('../lib/test.php');
require_once ('f:\wamp\www\simpletest\autorun.php');
require_once ('../lib/init.php');

class TestTemplate extends UnitTestCase {
    
    function setUp(){
        global $login_button;
        try{
        $me = getOneself();
        }catch(Exception $e){
            print($login_button);
            exit();
        }
    }
    
    //refer to http://www.simpletest.org/en/unit_test_documentation.html
    function testGetMyCommentActivities(){ 

                     
        //sample data from var_export
        $data =   array (
            'name' => 'myCommentQuery',
            'fql_result_set' => 
            array (
              0 => 
              array (
                'fromid' => '1246727707',
                'time' => '1288731243',
                'text' => 'Haha hooray~ :)',
              ),
              1 => 
              array (
                'fromid' => '1246727707',
                'time' => '1288750653',
                'text' => 'So ur gonna throw a party? ;)',
              ),
              2 => 
              array (
                'fromid' => '1246727707',
                'time' => '1287511435',
                'text' => 'Is your dissertation done? Wow, it\'s great!',
              ),
              3 => 
              array (
                'fromid' => '1246727707',
                'time' => '1287571050',
                'text' => 'No, it was meant to be lots of things there. It\'s working on my laptop but not on my supervisor\'s computer and not even on my wife\'s laptop.',
              ),
              4 => 
              array (
                'fromid' => '1246727707',
                'time' => '1286494937',
                'text' => 'Great, I envy you. Have a good trip!',
              ),
              5 => 
              array (
                'fromid' => '1246727707',
                'time' => '1283890349',
                'text' => 'I will be in Madrid tomorrow.',
              ),
              6 => 
              array (
                'fromid' => '1246727707',
                'time' => '1281123088',
                'text' => 'Well done! Keep steady :)',
              ),
              7 => 
              array (
                'fromid' => '1246727707',
                'time' => '1277115273',
                'text' => 'Is it a good news or a bad news?',
              ),
              8 => 
              array (
                'fromid' => '1246727707',
                'time' => '1275504590',
                'text' => 'Hooray~',
              ),
              9 => 
              array (
                'fromid' => '1246727707',
                'time' => '1275214952',
                'text' => 'I was thinking that Bank holiday is bank\'s holiday. ',
              )
        ));
        
        $id = 612139051;
        $activities = array();
        $activities = getFriendCommentActivities($data, $activities);
        
        $this->assertTrue(is_array($activities));
        $this->assertTrue(count($activities) == 5);
        
        
        print_r($activities);
    }
    
    function testRealData(){
        $id = 612139051;
        $data = getActivities($id);
        $myComment = getResultSet('myCommentQuery', $data);
        $activities = array();
        $activities = getMyCommentActivities($myComment, $activities);
        
        $myComment = $myComment['fql_result_set'];
        $numberOfComment = count($myComment);
        
        $this->assertTrue(is_array($activities));
        $this->assertEqual($numberOfComment, count($activities));
        print_r($activities);
    }
}
?>